package com.dw.article.controller;

import com.dw.common.entitys.BaseResponse;
import com.dw.common.utils.ResultUtils;
import com.dw.model.article.dtos.mapping.AddArticleMappingDTO;
import com.dw.model.article.entitys.ArticleMapping;
import com.dw.article.service.ArticleMappingService;
import com.dw.model.article.vos.article.QueryByIdVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 文章标签分类关系表(ArticleMapping)表控制层
 *
 * @author makejava
 * @since 2024-10-08 17:52:32
 */
@Slf4j
@RestController
@RequestMapping("/article/mapping")
public class ArticleMappingController {

    @Resource
    private ArticleMappingService articleMappingService;

    @PostMapping("/add")
    public BaseResponse<Boolean> addMapping(@RequestBody AddArticleMappingDTO addArticleMappingDTO) {
        log.info("添加文章分类标签关系表的参数:{}",addArticleMappingDTO);
        Boolean result = articleMappingService.addMapping(addArticleMappingDTO);
        return ResultUtils.success(result);
    }

    /**
     * 通过文章id查询关联分类和标签
     */
    @GetMapping("/queryById")
    public BaseResponse<QueryByIdVO> queryCategoryById(@RequestParam Long articleId) {
        QueryByIdVO result = articleMappingService.queryById(articleId);
        return ResultUtils.success(result);
    }

}

